package stdying.handyweibo.ui;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import stdying.handyweibo.AndroidApplication;
import stdying.handyweibo.injection.BaseActivtiyMoudle;
import stdying.handyweibo.injection.component.ApplicationComponent;

/**
 *
 */
public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       initInjector();
    }

    /**
     * 返回注入依赖的ApplicationComponent
     * @return
     */
    protected ApplicationComponent getApplicationComponent(){
        return ((AndroidApplication)getApplication()).getApplicationComponent();
    }

    protected BaseActivtiyMoudle getBaseActivtiyMoudle(){
        return new BaseActivtiyMoudle(this);
    }

    protected void addFragment(int containerViewId,Fragment fragment){
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.add(containerViewId,fragment);
        fragmentTransaction.commit();

    }

    /**
     * activity 跳转
     * @param target
     */
    protected void goToActivity(Intent target){

    }

    protected void initInjector(){}
}
